package com.matrix.java.chap_05;

import java.util.Scanner;

/*
    十进制到二进制
 */
public class Ex5_37 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("十进制数: ");
        int num = input.nextInt();
        input.close();
        System.out.println(Integer.toBinaryString(num));
        String binary = "";
        do {
            int i = num % 2;
            binary = i + binary;
            num /= 2;
        } while (num != 0);
        System.out.println(binary);
    }
}
